package com.wteam.clightmini.controller;


import com.wteam.clightmini.pojo.Menu;
import com.wteam.clightmini.service.MenuService;
import com.wteam.system.common.ResultMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 许则丕
 * @since 2022-07-12
 */
@RestController
@Api(tags = "系统：菜单")
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @PostMapping("/add")
    @ApiOperation("添加菜单")
    public ResultMessage add(Menu menu){
        return menuService.add(menu);
    }

    @PutMapping("/edit")
    @ApiOperation("编辑菜单")
    public ResultMessage edit(Menu menu){
        return menuService.edit(menu);
    }

    @DeleteMapping("/deleteMenu")
    @ApiOperation("删除菜单")
    public ResultMessage deleteMenu(Long id){
        return menuService.deleteMenu(id);
    }

    @GetMapping("/hiddenMenu")
    @ApiOperation("隐藏菜单")
    public ResultMessage hiddenMenu(Long id){
        return menuService.hiddenMenu(id);
    }

    @GetMapping("/listMenu")
    @ApiOperation("获取所有菜单")
    public List<Menu> listMenu(){
        return menuService.listMenu();
    }
}
